
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Modules.Workflow
Imports System.Linq

Namespace DotNetNuke.Modules.Workflow

    Partial Public Class Settings
        Inherits DotNetNuke.Entities.Modules.ModuleSettingsBase


#Region "Base Method Implementations"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' LoadSettings loads the settings from the Database and displays them
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Overrides Sub LoadSettings()
            Try
                If Not Page.IsPostBack Then

                    Dim objRoles As New DotNetNuke.Security.Roles.RoleController
                    Dim arrRoles As ArrayList = objRoles.GetPortalRoles(PortalId)

                    With ManageWorkflowRole
                        .DataTextField = "RoleName"
                        .DataValueField = "RoleId"
                        .DataSource = arrRoles
                        .DataBind()
                    End With
                    

                    Dim value As String = String.Empty
                    If Portals.PortalController.GetPortalSettingsDictionary(PortalId).TryGetValue("Workflow_ManageRole", value) Then
                        ManageWorkflowRole.SelectedValue = value
                    End If

                End If
            Catch exc As Exception    'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' UpdateSettings saves the modified settings to the Database
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Overrides Sub UpdateSettings()
            Try

                Portals.PortalController.UpdatePortalSetting(PortalId, "Workflow_ManageRole", ManageWorkflowRole.SelectedValue)

            Catch exc As Exception    'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

#End Region

    End Class

End Namespace


